package com.ctshk.sapp.scenic.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.enums.SystemError;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.scenic.dto.ScenicPriceDTO;
import com.ctshk.rpc.scenic.dto.ScenicReservationGetOrderDTO;
import com.ctshk.rpc.scenic.dto.ScenicReservationListDTO;
import com.ctshk.rpc.scenic.dto.ScenicTicketDetailsDTO;
import com.ctshk.rpc.scenic.req.ScenicReservationListReq;
import com.ctshk.rpc.scenic.req.ScenicReservationOrderReq;
import com.ctshk.rpc.scenic.service.IScenicReservationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Objects;


/**
 * <p>
 *  预订中心景点门票 前端控制器
 * </p>
 *
 * @author 张志朋
 * @since 2/22/2021
 */

@Api(value="预订中心景点门票", tags="预订中心景点门票")
@RestController
@RequestMapping("/scenic/reservation")
public class ScenicReservationController extends BaseController {

    @DubboReference
    private IScenicReservationService iScenicReservationService;

    @ApiOperation(value = "预订中心景点门票列表", notes = "预订中心景点门票列表")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "景点门票列表", operDesc = "景点门票列表")
    @PostMapping(value = "/list")
    public Result<PageResponse<ScenicReservationListDTO>> queryList(@RequestBody ScenicReservationListReq reservationListReq){
        PageResponse<ScenicReservationListDTO> result = iScenicReservationService.queryList(reservationListReq,getCurrentUser(getRequest()));
        return Result.success(result);
    }

    @ApiOperation(value = "预订中心景点门票详情页查询", notes = "预订中心景点门票详情页查询")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "预订中心景点门票详情页查询", operDesc = "预订中心景点门票详情页查询")
    @GetMapping("/info/{id}")
    public Result<ScenicTicketDetailsDTO> query(@PathVariable Long id){
        ScenicTicketDetailsDTO detailsDTO = iScenicReservationService.query(id,getCurrentUser(getRequest()));
        if(detailsDTO==null){
            return Result.failed(SystemError.SCENIC_5006);
        }
        return Result.success(detailsDTO);
    }

    @ApiOperation(value = "预订中心景点门票默认推荐页", notes = "预订中心景点门票默认推荐页")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "预订中心景点门票默认推荐页", operDesc = "预订中心景点门票默认推荐页")
    @GetMapping("/recommended/info")
    public Result<List<ScenicReservationListDTO>> recommendedList(){
        List<ScenicReservationListDTO> result = iScenicReservationService.recommendedList(getCurrentUser(getRequest()));
        return Result.success(result);
    }

    @ApiOperation(value = "预订中心景点门票-填写订单页-根据产品id获取订单信息", notes = "预订中心景点门票-填写订单页-根据产品id获取订单信息")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "预订中心景点门票-填写订单页-根据产品id获取订单信息", operDesc = "预订中心景点门票-填写订单页-根据产品id获取订单信息")
    @PostMapping("/get-order")
    public Result<ScenicReservationGetOrderDTO>getOrderInfo(@RequestBody ScenicReservationOrderReq scenicReservationOrderReq){
        ScenicReservationGetOrderDTO result = iScenicReservationService.getOrderInfo(scenicReservationOrderReq);
        return Result.success(result);
    }
}












